// src/api/daohanApi.ts
import axios from 'axios';

const API_URL = 'https://api.daohantianqiong.com/chat'; // 替换为实际的API地址
const API_KEY = 'your-api-key'; // 替换为你的API密钥

interface ChatMessage {
  role: 'user' | 'assistant';
  content: string;
}

export const sendChatMessage = async (messages: ChatMessage[]): Promise<string> => {
  try {
    const response = await axios.post(API_URL, {
      messages,
      model: 'default', // 根据API文档选择合适的模型
    }, {
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json',
      },
    });

    return response.data.choices[0].message.content;
  } catch (error) {
    console.error('API请求失败:', error);
    throw error;
  }
};